fix: validate devtoolsOptionsUri in extensionEnabledState handler#9834
Open
adilburaksen wants to merge 2 commits into
Open
fix: validate devtoolsOptionsUri in extensionEnabledState handler#9834adilburaksen wants to merge 2 commits into
adilburaksen wants to merge 2 commits into
Conversation
…ledState handleExtensionEnabledState() accepted the devtoolsOptionsUri query parameter without validation and passed it directly to DevToolsOptions.setExtensionEnabledState(), which creates the file and parent directories if they do not exist. An untrusted caller could supply an arbitrary file: URI to create or overwrite any path writable by the DevTools server process. Add a guard that rejects URIs whose scheme is not 'file' or whose path does not end with 'devtools_options.yaml'. Both conditions must hold for a legitimate devtools options file.
Contributor
There was a problem hiding this comment.
Code Review
This pull request adds validation for the devtoolsOptionsUri query parameter to ensure it is a local file URI pointing to a devtools_options.yaml file, mitigating potential file overwrite vulnerabilities. Feedback was provided to tighten the path validation logic, as the current implementation could match unintended filenames.
endsWith('devtools_options.yaml') matched paths like
'not_devtools_options.yaml'. Adding the path separator prefix
ensures only files literally named 'devtools_options.yaml' are accepted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handleExtensionEnabledState()in_devtools_extensions.dartreadsdevtoolsOptionsUridirectly from query parameters and passes it without validation toDevToolsOptions.setExtensionEnabledState(), which creates the target file and any missing parent directories.An untrusted caller that can reach the DevTools server (e.g., another local process, or a browser tab via cross-origin requests) can create or overwrite any file writable by the server process:
The resulting file content is a valid YAML map:
Fix
Reject requests where
devtoolsOptionsUri:file:scheme, ordevtools_options.yamlBoth conditions are required for a legitimate DevTools options file. Any other value is rejected with HTTP 400.
Impact
Without the fix, any local process or browser tab able to reach the DevTools HTTP server can create or overwrite arbitrary files on the developer's machine with attacker-controlled YAML content.